<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>YK Value-added System</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<link rel="stylesheet" type="text/css" href="css/admin.css" />
	<link rel="stylesheet" type="text/css" href="css/common.css" />
	<script src="<%=basePath%>js/json.js" charset="utf-8" type="text/javascript"></script>
	<script src="<%=basePath%>js/prototype.js" charset="utf-8" type="text/javascript"></script>
	<script type="text/javascript">
		function check(){
			if(document.getElementById("oldPwd").value==""){
				alert("原始密码不能为空！");
				document.getElementById("oldPwd").focus();
				return false ;
			}
			if(document.getElementById("password").value==""){
				alert("密码不能为空！");
				document.getElementById("password").focus();
				return false ;
			}
			if(document.getElementById("password2").value==""){
				alert("再次输入密码不能为空！");
				document.getElementById("password2").focus();
				return false ;
			}
			if(document.getElementById("password").value!=document.getElementById("password2").value){
				alert("两次输入密码不一致!");
				return false ;
			}
			
			var judgment2;
			var username=encodeURIComponent("${username}");
			var id="${id}";
			var password=document.getElementById("oldPwd").value;
			var url1 = "<%=basePath%>admin/login!checkUser.action?password="+password+"&username="+username;
	        new Ajax.Request(url1,{method:'post',asynchronous:false,
	           	onComplete:function(json){
	           	judgment2=json.responseText.parseJSON().judgment2;
			    if(judgment2=="1"){
			    	alert("原始密码输入错误！");
			    }
	           }
	        });
	        password=document.getElementById("password").value;
	        var url2 = "<%=basePath%>/admin/system/userMgr/userMgr!changePwdByUser.action?password="+password+"&id="+id;
	        if(judgment2=="0"){
	         	new Ajax.Request(url2,{method:'post',asynchronous:false,
		           	onComplete:function(json){
			           alert("密码修改成功！");
		           }
		        });
	        }else{
	         	return false;
	        }
		}
		
		function check_value(id){
		    var value=document.getElementById(id).value;
		    if(value.indexOf(' ')>-1){
		    	alert("不能包含空格！");
		    	document.getElementById(id).value="";
		    	return false;
		    }
		    return true;
		}
		
	</script>
  </head>
  
  <body>
<table width="95%" border="0" align="center" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0">
      <tr>
        <td width="30"><img src="images/location_left.gif" width="24" height="30" /></td>
        <td>
        	您当前的位置是：系统管理 -&gt;用户修改密码<br>
        </td>
      </tr>
      <tr>
          <td colspan="2"><hr width="80%" align="left"></td>
		</tr>
    </table></td>
  </tr>
  <tr>
    <td><form id="form1" name="form1" method="post" onsubmit="return check();">
      <table width="100%" border="0" cellspacing="3">
      <tr>
          <td><font color="red" style="font-size:12px;"></font></td>
         <td>
          <font color="red" style="font-size:12px;"><s:actionmessage/><s:actionerror/></font>
          </td>
		</tr>
        <tr>
          <td width="100" align="right">
          	<span class="style">*</span>用户名：
          </td>
          <td>
          	${username}
          </td>
        </tr>
        <tr>
          <td style="width:100px" align="right">
          	<span class="style">*</span>原始密码：
          </td>
          <td>
          	<input  type="password" style="width:150px" id="oldPwd" name="oldPwd" maxlength="30" value="" onkeyup="check_value(this.id);"/>
          </td>
        </tr>
        <tr>
          <td style="width:100px" align="right">
          	<span class="style">*</span>新密码：
          </td>
          <td>
          	<input  type="password" style="width:150px" id="password" name="password" maxlength="30" value="" onkeyup="check_value(this.id);"/>
          </td>
        </tr>
        <tr>
          <td style="width:100px" align="right">
          	<span class="style">*</span>确认密码：
          </td>
          <td>
          	<input type="password" style="width:150px" id="password2" name="password2" maxlength="30" value="" onkeyup="check_value(this.id);"/>
          </td>
        </tr>
		<tr>
          <td colspan="2"><hr width="80%" align="left"></td>
		</tr>
        <tr>
          <td align="right"><input type="submit" name="Submit" value="修改" class="Button" /></td>
        </tr>
      </table>
        </form>
    </td>
  </tr>
</table>
</body>
</html>
